package cn.t.converter.order;


import cn.t.core.converter.CoreDTOConverter;
import cn.t.dto.order.OverPickupOrderDTO;
import cn.t.dto.order.OverPickupRecordDTO;
import cn.t.enums.TimeLimitTypeEnum;
import cn.t.model.order.OverPickupRecordDO;
import cn.t.model.order.OverPickupRecordVO;
import cn.t.utils.DateUtil;
import org.mapstruct.Mapper;

import java.util.Date;

/**
 * 超领记录表(OverPickupRecord)dto转domain
 *
 * @author t
 * @since 2024-05-24 10:19:34
 */
@Mapper(componentModel = "spring")
public interface OverPickupRecordDTOConverter extends CoreDTOConverter<OverPickupRecordDTO, OverPickupRecordDO> {
    OverPickupOrderDTO do2DtoBean(OverPickupRecordVO overPickupRecordDO);

    default Date getTimeLimit(TimeLimitTypeEnum timeLimitType, int quantityLimit) {

        if ( timeLimitType.getCode() <= 0 || quantityLimit == -1) {
            return null;
        }
        switch (timeLimitType) {
            case EVERY_DAY: {
                return DateUtil.currentDaily();
            }
            case WEEKLY: {
                return DateUtil.currentWeekly();
            }
            case SEMI_ANNUAL: {
                return DateUtil.currentHalfYearly();
            }
            case EVERY_MONTH: {
                return DateUtil.currentMonthly();
            }
            case EVERY_YEAR: {
                return DateUtil.currentYearly();
            }
            default: {
                return null;
            }
        }
    }
}

